﻿using System;
using DflyingForum.Core.Data.Domain.Entities;

namespace DflyingForum.Core.Repositories
{
    public class TopicReposity : NHibernateRepository<Topic, int>
    {
        public void MoveTopic(Topic from, Topic to)
        {
            int fromSort = from.Sort;
            int toSort = to.Sort;

            //交换sort
            from.Sort = toSort;
            to.Sort = fromSort;
            base.Update(from);
            base.Update(to);
        }

        public void MoveTopic(int fromId, int toId)
        {
            Topic from = base.FindBy(fromId);
            Topic to = base.FindBy(toId);
            this.MoveTopic(from, to);
        }
    }
}